﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication1.Base
{
    public class DbSql
    {
        public static SqlSugarClient DB
        {
            get
            {
                //创建数据库对象 (用法和EF Dappper一样通过new保证线程安全)
                //可以在连接字符串中设置连接池pooling=true;表示开启连接池
                //eg:min pool size=2;MaxPoolSize=4;表示最小连接池为2，最大连接池是4；默认是100
                SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
                {
                    DbType = SqlSugar.DbType.MySql,
                    ConnectionString = "server=rm-2ze29it63mpgq7l0iuo.mysql.rds.aliyuncs.com;port=3306;database=base;uid=wangshuyu01;pwd=WangShuYu01@654321;CharSet=utf8mb4;Allow User Variables=True;sslMode=None;",
                    IsAutoCloseConnection = true,
                    InitKeyType = InitKeyType.Attribute //从实体特性中读取主键自增列信息
                });
                return db;
            }
        } 
    }
}